package com.aktk.gameelements;

import com.aktk.gameelements.GamePlay.Orientation;

public class Player{
	
	public String name;		// Player's name
	Fleet navy;			// Fleet of player's ships
	public Player opponent;	// Player's opponent Player
	public Map opponentMap;		// Player's field Map, identifying checked locations
	public Map incommingShots;

	// Default Constructor
	public Player( String playerName , int numShips, int numRows , int numCols ) {
		name = playerName;
		opponentMap = new Map( numRows , numCols );
		incommingShots = new Map( numRows , numCols );
		navy = new Fleet( numShips );
	}	
	
	// Sets the player's display name
	public void setName( String playerName ) {
		name = playerName;
	}
	
	public void addShip( int row , int col , int l , Orientation o ) {
		navy.addShip(row, col, l, o);
	}
	
	// Checks if coordinates of opponent's board has been previously checked
	/*public boolean alreadyChecked( int x , int y ) {
		return opponent.playerMap.Checked(x, y);
	}*/
		
	// Fires missile at coordinate location of opponent's board
	public boolean fireMissile( int row , int col ) {
		return opponent.inMissile( row , col );
	}
		
	// Receives missile at coordinate location
	public boolean inMissile( int row , int col ) {
		return navy.inMissile( row , col ); 
	}
	
	public int getFleetSize( ) {
		return navy.getFleetSize(); 
	}
	
	public Ship getShip( int index ) {
		return navy.getShip( index ); 
	}
	
	public int getShipsRemaining() {
		int shipsRemaining = 0;
		for( int a = 0 ; a < navy.getFleetSize() ; ++a )
		{
			if( !getShip(a).isSunk() )
			{
				++shipsRemaining;
			}
		}
		return shipsRemaining; 
	}
}
